package jmm;

public class GetSingleTest {

    public static void main(String[] args) {
        for (int i = 0; i < 100000000; i++) {

            Thread thread1 = new Thread(() -> {
                SingleDemo instance = SingleDemo.getInstance();
                System.out.println(instance.hashCode());
            });

            Thread thread2 = new Thread(() -> {
                SingleDemo instance = SingleDemo.getInstance();
                System.out.println(instance.hashCode());
            });

            Thread thread3 = new Thread(() -> {
                SingleDemo instance = SingleDemo.getInstance();
                System.out.println(instance.hashCode());
            });

            thread1.start();
            thread2.start();
            thread3.start();
            try {
                thread1.join();
                thread2.join();
                thread3.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
